#include "entity.h"
#include "response.h"
#include "structure.h"
#include "fileManager.h"
#include "utils.h"
/**
 * @brief 根据命令做出对应处理
*/
void response(int net_fd, unsigned short command, char *parameter){
    switch (command){
        case DATA:
            break;

        case LOGIN:
            // 
            break;

        case REGISTER:
            // 
            break;

        case CD:
            // 切换目录
            break;

        case LS:
            dealListDirectoryContent(net_fd,parameter);
            break;

        case PWD:
            // 返回当前目录
            printWorkingDirectory(net_fd);
            break;

        case PUT_FILE:
            // 上传文件
            putFile(net_fd, parameter);
            break;

        case GET_FILE:
            // 下载文件
            sendFile(net_fd,parameter);
            //sendFile(net_fd);
            break;
            
        case RM:
            // 删除文件
            break;

        case MKDIR:
            // 创建目录
           
            break;

    }
}

void sendError(int net_fd){
    unsigned short flag = 0;
    unsigned int frameLength = sizeof flag;
    send(net_fd, &frameLength, sizeof frameLength, MSG_NOSIGNAL);
    send(net_fd, &flag, sizeof flag, MSG_NOSIGNAL);
}

void sendSuccess(int net_fd){
    unsigned short flag = 1;
    unsigned int frameLength = sizeof flag;
    send(net_fd, &frameLength, sizeof frameLength, MSG_NOSIGNAL);
    send(net_fd, &flag, sizeof flag, MSG_NOSIGNAL);
}
